# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Luca Weiss <luca@lucaweiss.eu>
pkgname=mir
pkgver=2.15.0
pkgrel=4
pkgdesc="Mir Display Server"
url="https://mir-server.io"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.0-or-later"
depends="
	ttf-freefont
	xkeyboard-config
	"
depends_dev="
	boost-dev
	capnproto-dev
	eudev-dev
	freetype-dev
	gflags-dev
	glib-dev
	glm-dev
	glog-dev
	libepoxy-dev
	libevdev-dev
	libinput-dev
	libxcursor-dev
	libxkbcommon-dev
	libxml++-2.6-dev
	lttng-ust-dev
	mesa-dev
	nettle-dev
	protobuf-dev
	umockdev-dev
	wayland-dev
	yaml-cpp-dev
	"
makedepends="
	$depends_dev
	cmake
	gmock
	gtest-dev
	lttng-ust-tools
	py3-pillow
	samurai
	wlcs-dev
	"
checkdepends="
	bash
	grep
	wlcs
	"
source="https://github.com/MirServer/mir/releases/download/v$pkgver/mir-$pkgver.tar.xz
	0001-Fix-the-signature-of-drmModeCrtcSetGamma.patch
	0002-Drop-unused-dependency-on-gflags.patch
	0003-Strip-out-the-glog-example.patch
	0004-Missing-algorithm-header-for-gcc14.patch
	"
subpackages="$pkgname-dev $pkgname-demos $pkgname-test-tools:test_tools"
options="!check" # some tests fail/hang currently, to be debugged

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		-DMIR_FATAL_COMPILE_WARNINGS=OFF \
		-DMIR_ENABLE_WLCS_TESTS=OFF \
		-DMIR_USE_LD=ld
	cmake --build build
}

check() {
	XDG_RUNTIME_DIR=/tmp ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev
	amove usr/bin/mir_wayland_generator
}

demos() {
	pkgdesc="$pkgdesc - demonstration programs"
	amove usr/bin/miral-shell
	amove usr/bin/miral-kiosk
	amove usr/bin/miral-app
	amove usr/bin/miral-terminal
	amove usr/bin/mir-shell
	amove usr/bin/miral-system-compositor
	amove usr/share/applications/miral-shell.desktop
	amove usr/share/wayland-sessions/mir-shell.desktop
	amove usr/share/icons/hicolor/scalable/apps/ubuntu-logo.svg
}

test_tools() {
	pkgdesc="$pkgdesc - stress tests and other test tools"
	amove usr/bin/mir_performance_tests
	amove usr/bin/mir-smoke-test-runner
	amove usr/bin/mir_platform_graphics_test_harness
	amove usr/lib/mir/tools/libmirserverlttng.so
	amove usr/bin/mir_demo_client_*
	amove usr/bin/mir_demo_server
	amove usr/lib/mir/server-platform/graphics-dummy.so
	amove usr/lib/mir/server-platform/input-stub.so
}

sha512sums="
b8a5ed4326a6257595873c35d683a343fc96840d1b2824af6478c59db44cc8d0eea9984b74db09ae101885d457d83fa4faa37992b755b92f3e7712b1c09072cd  mir-2.15.0.tar.xz
e1e9884a6537419e7d2ca85c03b8dbc1225fc1eed6aaa8d9908eaf84cd1c5776ef393f55fe14f2328686e11aa9a246da0f79d431f564ba69106f418da4a66127  0001-Fix-the-signature-of-drmModeCrtcSetGamma.patch
fa5762030ae82fb7c85f9f8edbd2f477da0a4790ff27af557815f91a40d7184d96f0789faabab79988a0fbe374f7cddc5dcd416ffb6930c7ffcf7b4d362b4538  0002-Drop-unused-dependency-on-gflags.patch
4442d3bfe401eb6a63634e2c84b85c0d18d48e50f94328d094bd618980abe43b305a3ef46461dbd22c4693ee5c130fb509b4550acc8c18409be0b69b77909af4  0003-Strip-out-the-glog-example.patch
210b3c8b5336651610d2ecf32f1d734e204a668193f5f1746fce9ca7d3f237a025d7fb849b1b5ef80a8e08b07627541bd1d8c3f7be5b8c3803f08c3988d4f335  0004-Missing-algorithm-header-for-gcc14.patch
"
